home *** CD-ROM | disk | FTP | other *** search
/ QRZ! Ham Radio 1 / QRZ Ham Radio Callsign Database - December 1993.iso / ucsd / packet / tcpip / sys5 / iscwmpst.z / iscwmpst / tcp / src / global.h < prev    next >
Encoding:
C/C++ Source or Header  |  1991-06-19  |  6.4 KB  |  236 lines

  1. /* @(#) $Header: global.h,v 1.13 91/06/18 17:26:53 deyke Exp $ */
  2.  
  3. #ifndef _GLOBAL_H
  4. #define _GLOBAL_H
  5.  
  6. /* Global definitions used by every source file.
  7.  * Some may be compiler dependent.
  8.  */
  9.  
  10. #if     defined(__TURBOC__) || defined(__STDC__) || defined(LATTICE)
  11. #define ANSIPROTO       1
  12. #else
  13. #define const
  14. #endif
  15.  
  16. #ifndef __ARGS
  17. #ifdef  ANSIPROTO
  18. #define __ARGS(x)       x
  19. #else
  20. #define __ARGS(x)       ()
  21. #endif
  22. #endif
  23.  
  24. #if     !defined(AMIGA) && (defined(LATTICE) || defined(MAC) || defined(__TURBOC__))
  25. /* These compilers require special open modes when reading binary files.
  26.  *
  27.  * "The single most brilliant design decision in all of UNIX was the
  28.  * choice of a SINGLE character as the end-of-line indicator" -- M. O'Dell
  29.  *
  30.  * "Whoever picked the end-of-line conventions for MS-DOS and the Macintosh
  31.  * should be shot!" -- P. Karn's corollary to O'Dells' declaration
  32.  */
  33. #define READ_BINARY     "rb"
  34. #define WRITE_BINARY    "wb"
  35. #define APPEND_BINARY   "ab+"
  36. #define READ_TEXT       "rt"
  37. #define WRITE_TEXT      "wt"
  38. #define APPEND_TEXT     "at+"
  39.  
  40. #else
  41.  
  42. #define READ_BINARY     "r"
  43. #define WRITE_BINARY    "w"
  44. #define APPEND_BINARY   "a+"
  45. #define READ_TEXT       "r"
  46. #define WRITE_TEXT      "w"
  47. #define APPEND_TEXT     "a+"
  48.  
  49. #endif
  50.  
  51. /* These two lines assume that your compiler's longs are 32 bits and
  52.  * shorts are 16 bits. It is already assumed that chars are 8 bits,
  53.  * but it doesn't matter if they're signed or unsigned.
  54.  */
  55. typedef int int32;              /* 32-bit signed integer */
  56. typedef unsigned short int16;   /* 16-bit unsigned integer */
  57. typedef unsigned char byte_t;   /*  8-bit unsigned integer */
  58. #define uchar(x) ((unsigned char)(x))
  59. #define MAXINT16 65535          /* Largest 16-bit integer */
  60. #define MAXINT32 4294967295L    /* Largest 32-bit integer */
  61.  
  62. #define HASHMOD 7               /* Modulus used by hash_ip() function */
  63.  
  64. /* The "interrupt" keyword is non-standard, so make it configurable */
  65. #if     defined(__TURBOC__) && defined(MSDOS)
  66. #define INTERRUPT       void interrupt
  67. #else
  68. #define INTERRUPT       void
  69. #endif
  70.  
  71. /* Note that these definitions are on by default if none of the Turbo-C style
  72.  * memory model definitions are on; this avoids having to change them when
  73.  * porting to 68K environments.
  74.  */
  75. #if     !defined(__TINY__) && !defined(__SMALL__) && !defined(__MEDIUM__)
  76. #define LARGEDATA       1
  77. #endif
  78.  
  79. #if     !defined(__TINY__) && !defined(__SMALL__) && !defined(__COMPACT__)
  80. #define LARGECODE       1
  81. #endif
  82.  
  83. /* Since not all compilers support structure assignment, the ASSIGN()
  84.  * macro is used. This controls how it's actually implemented.
  85.  */
  86. #ifdef  NOSTRUCTASSIGN  /* Version for old compilers that don't support it */
  87. #define ASSIGN(a,b)     memcpy((char *)&(a),(char *)&(b),sizeof(b));
  88. #else                   /* Version for compilers that do */
  89. #define ASSIGN(a,b)     ((a) = (b))
  90. #endif
  91.  
  92. /* Define null object pointer in case stdio.h isn't included */
  93. #ifndef NULL
  94. /* General purpose NULL pointer */
  95. #define NULL (void *)0
  96. #endif
  97. #define NULLCHAR (char *)0      /* Null character pointer */
  98. #define NULLCHARP (char **)0    /* Null character pointer pointer */
  99. #define NULLINT (int *)0        /* Null integer pointer */
  100. #define NULLFP   (int (*)())0   /* Null pointer to function returning int */
  101. #define NULLVFP  (void (*)())0  /* Null pointer to function returning void */
  102. #define NULLVIFP (INTERRUPT (*)())0
  103. #define NULLFILE (FILE *)0      /* Null file pointer */
  104.  
  105. /* standard boolean constants */
  106. #define FALSE 0
  107. #define TRUE 1
  108. #define NO 0
  109. #define YES 1
  110.  
  111. /* string equality shorthand */
  112. #define STREQ(x,y) (strcmp(x,y) == 0)
  113.  
  114. /* Extract a short from a long */
  115. #define hiword(x)       ((int16)((x) >> 16))
  116. #define loword(x)       ((int16)(x))
  117.  
  118. /* Extract a byte from a short */
  119. #define hibyte(x)       ((unsigned char)((x) >> 8))
  120. #define lobyte(x)       ((unsigned char)(x))
  121.  
  122. /* Extract nibbles from a byte */
  123. #define hinibble(x)     (((x) >> 4) & 0xf)
  124. #define lonibble(x)     ((x) & 0xf)
  125.  
  126. /* Various low-level and miscellaneous functions */
  127. unsigned long availmem __ARGS((void));
  128. void *callocw __ARGS((unsigned nelem,unsigned size));
  129. int dirps __ARGS((void));
  130. int getopt();
  131. int htoi __ARGS((char *));
  132. long htol __ARGS((char *));
  133. char *inbuf __ARGS((int16 port,char *buf,int16 cnt));
  134. int16 hash_ip __ARGS((int32 addr));
  135. int istate __ARGS((void));
  136. void log();
  137. int log2 __ARGS((int x));
  138. #define ltop(x) ((void *) (x))
  139. void *mallocw __ARGS((unsigned nb));
  140. char *outbuf __ARGS((int16 port,char *buf,int16 cnt));
  141. #define ptol(x) ((long) (x))
  142. void restore __ARGS((int));
  143. void rflush __ARGS((void));
  144. void rip __ARGS((char *));
  145. char *smsg __ARGS((char *msgs[],unsigned nmsgs,unsigned n));
  146. int tprintf __ARGS((char *fmt,...));
  147. #if     !defined __TURBOC__
  148. char *strdup();
  149. #endif
  150. int wildmat __ARGS((char *s,char *p,char **argv));
  151.  
  152. #define tprintf printf
  153. #include <stdlib.h>
  154. #include <string.h>
  155.  
  156. int stricmp __ARGS((char *s1, char *s2));
  157. int strnicmp __ARGS((char *s1, char *s2, size_t maxlen));
  158.  
  159. #ifdef  AZTEC
  160. #define rewind(fp)      fseek(fp,0L,0);
  161. #endif
  162.  
  163. #if     defined(__TURBOC__) && defined(MSDOS)
  164. #define movblock(so,ss,do,ds,c) movedata(ss,so,ds,do,c)
  165. #ifndef outportw
  166. #define outportw outport
  167. #endif
  168. #ifndef inportw
  169. #define inportw inport
  170. #endif
  171.  
  172. #else
  173.  
  174. /* General purpose function macros already defined in turbo C */
  175. #ifndef min
  176. #define min(x,y)        ((x)<(y)?(x):(y))       /* Lesser of two args */
  177. #endif
  178. #ifndef max
  179. #define max(x,y)        ((x)>(y)?(x):(y))       /* Greater of two args */
  180. #endif
  181. #ifdef  MSDOS
  182. #define MK_FP(seg,ofs)  ((void far *) \
  183.             (((unsigned long)(seg) << 16) | (unsigned)(ofs)))
  184. #endif
  185. #endif  /* __TURBOC __ */
  186.  
  187. #ifdef  AMIGA
  188. /* super kludge de WA3YMH */
  189. #ifndef fileno
  190. #include <stdio.h>
  191. #endif
  192. #define fclose(fp)      amiga_fclose(fp)
  193. extern int amiga_fclose __ARGS((FILE *));
  194. extern FILE *tmpfile __ARGS((void));
  195.  
  196. extern char *sys_errlist[];
  197. extern int errno;
  198. #endif
  199.  
  200. /* Externals used by getopt */
  201. extern int optind;
  202. extern char *optarg;
  203.  
  204. /* Threshold setting on available memory */
  205. extern int32 Memthresh;
  206.  
  207. /* System clock - count of ticks since startup */
  208. extern int32 Clock;
  209.  
  210. /* Various useful standard error messages */
  211. extern char Badhost[];
  212. extern char Nospace[];
  213. extern char Notval[];
  214. extern char *Hostname;
  215. extern char Version[];
  216.  
  217. /* Your system's end-of-line convention */
  218. extern char Eol[];
  219.  
  220. extern void (*Gcollect[])();
  221.  
  222. struct ax25_cb;
  223. struct dirsort;
  224. struct iface;
  225. struct ip;
  226. struct mbx;
  227. struct mbuf;
  228. struct nr4cb;
  229. struct session;
  230. struct slip;
  231.  
  232. extern int Debug;
  233. extern int Shortstatus;
  234.  
  235. #endif  /* _GLOBAL_H */
  236.